const Router = require('koa-router')
const { create, findlist, findById } = require(':controllers/itemList')
const { JWTgetToken, JWTgetInfo } = require(':JWT')
const router = new Router({ prefix: '/itemList' }) 

const auth = async(ctx, next) => {
    const { token = '' } = ctx.request.header
    console.log(ctx.request)
    try {
      ctx.state.userInfo = JWTgetInfo(token)
    } catch (err) {
      ctx.throw(401)
    }
    await next()
  }

//获取列表
router.get('/',findlist)

router.put('/', create)

module.exports = router
